import { commonParams } from './config.js'

export function getTopList(callback){
  const data = Object.assign({},commonParams,{
    platform: 'h5',
    needNewCode: 1
  });
  wx.request({
    url: 'https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg',
    data:data,
    success(res){
      let jsonData = {};
      if(res.statusCode == 200){
        if (typeof(res.data) === "string"){
          jsonData = JSON.parse(res.data.replace('MusicJsonCallback(', '').slice(0, -1));
        }
        callback(jsonData)
      }else{}
    }
  })
}
// 排行榜详情
export function getMusicList(topid,callback){
  const data = Object.assign({},commonParams,{
    topid,
    page: 'detail',
    type: 'top',
    tpl: 3,
    platform: 'h5',
    needNewCode: 1
  });
  wx.request({
    url: 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg',
    data:data,
    success(res){
      if(res.statusCode == 200){
        callback(res.data)
      }else{}
    }
  })
}
